import conversion_send_icon from '@/assets/image/conversion_send.png';
import {
  feedbacksComment,
  helpChat,
  search_feedback,
} from '@/services/ant-design-pro/conversation';
import {
  freeIntention,
  freeSearch,
  mainPointTitle,
  viewpoints,
} from '@/services/ant-design-pro/highClassWrite';
import { AILogsCon } from '@/services/models/dataDoc';
import { isNotEmpty } from '@/utils';
import { CloseCircleOutlined } from '@ant-design/icons/lib/icons';
import { Button, Form, Input, message } from 'antd';
import { nanoid } from 'nanoid';
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
import { connect } from 'umi';
import AiCommandLogs from './aiCommandLogs';
import UploadFile from './com/UploadFile';
import './index.less';
const Command: React.FC<any> = forwardRef((props: any, ref) => {
  const { generate, visible, stopStruct, showProgress } = props;
  const [ipt, setIpt] = useState<string>('');
  const [aiLogs, setAILogs] = useState<AILogsCon[]>([]); //对话框对话列表
  const [orderSelect, setOrderSelect] = useState('1'); //指令 or 聊天
  const [form] = Form.useForm();
  const [showUpload, setShowUpload] = useState<boolean>(false); //上传文件框是否出现
  const [iptPlaceholder, setIptPlaceholder] = useState<string>(''); //输入框的placeholder文案
  const messagesEnd = useRef<HTMLDivElement>(null);
  const AiCommandLogsRef = useRef<any>(null);
  const [highClassHandle] = useState<any[]>([
    {
      type: 'findInfo',
      name: '找参考资料',
      systemRecover: '请问需要小麦帮您查找什么资料？', //系统自动回复的文案
    },
    {
      type: 'uploadInfo',
      name: '上传参考资料',
      systemRecover: '好的，请发送参考资料',
    },
    {
      type: 'inspireIdeas',
      name: '启发写作思路',
      systemRecover: '请告诉我文章的主题',
    },
    {
      type: 'generateArticle',
      name: '生成文章',
      systemRecover: '',
    },
  ]); //对话框对话列表

  //存储在页面model的数据
  const { curOperationType, currentDocIndex, robotLoading, documentUUID, writing_session_id } =
    props.highClassWrite;

  //公共更新model的方法
  const updateState = (updateObj: any) => {
    props.dispatch({
      type: 'highClassWrite/updateState',
      payload: updateObj,
    });
  };

  //滑动到底部
  const scrollToBottom = (targetClassName = '', speed = 30, index = 0) => {
    if (messagesEnd && messagesEnd.current) {
      const element = messagesEnd.current;
      let targetPosition = element.scrollHeight;

      if (targetClassName) {
        const targetElement: any = element.querySelectorAll(targetClassName);
        if (targetElement.length > 0) {
          // 获取 NodeList 中的最后一个元素
          const lastTargetElement = targetElement[index];
          targetPosition = lastTargetElement.offsetTop - lastTargetElement.offsetHeight;
          // targetPosition = targetElement?.offsetTop - targetElement?.offsetHeight; // 考虑到滚动到元素顶部
        } else {
          console.error(`找不到 '${targetClassName}'`);
          return; // 如果找不到元素，直接返回，不执行滚动操作
        }
      }

      const startPosition = element.scrollTop;
      const duration = (Math.abs(targetPosition - startPosition) / speed) * 10;
      const startTime = performance.now();

      const animation = (currentTime: any) => {
        const elapsedTime = currentTime - startTime;
        const currentPosition =
          startPosition + ((targetPosition - startPosition) / duration) * elapsedTime;
        element.scrollTop = currentPosition;

        if (elapsedTime < duration) {
          requestAnimationFrame(animation);
        }
      };

      requestAnimationFrame(animation);
    }
  };
  //滑动到某个元素
  //滑动到底部
  const scrollToEle = (targetClassName = '', speed = 30, index = 0) => {
    if (messagesEnd && messagesEnd.current) {
      const element = messagesEnd.current;
      let targetPosition = element.scrollHeight;

      if (targetClassName) {
        const targetElement: any = element.querySelectorAll(targetClassName);
        if (targetElement.length > 0) {
          // 获取 NodeList 中的最后一个元素
          const lastTargetElement = targetElement[index];
          targetPosition = lastTargetElement.offsetTop;
        } else {
          console.error(`找不到 '${targetClassName}'`);
          return; // 如果找不到元素，直接返回，不执行滚动操作
        }
      }

      const startPosition = element.scrollTop;
      const duration = (Math.abs(targetPosition - startPosition) / speed) * 10;
      const startTime = performance.now();

      const animation = (currentTime: any) => {
        const elapsedTime = currentTime - startTime;
        const currentPosition =
          startPosition + ((targetPosition - startPosition) / duration) * elapsedTime;
        element.scrollTop = currentPosition;

        if (elapsedTime < duration) {
          requestAnimationFrame(animation);
        }
      };

      requestAnimationFrame(animation);
    }
  };
  //生成文章 - 发送
  const generateArticle = (keyword: any) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '',
      });
      return;
    }

    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    const item_user: AILogsCon = {
      key: +new Date() + Math.random(),
      type: 'user',
      user_command: keyword,
    };
    const aiLogsCopy = [...aiLogs];
    aiLogsCopy.push(item_user);
    setAILogs(aiLogsCopy);

    generate(keyword); //调用父页面的发送接口
  };
  const submitZanCai = async () => {
    updateState({
      robotLoading: true,
    });
    //用户输入 如果没有输入 点赞使用 这个内容写得很好，值得表扬 点踩使用 这个内容有待提高，需要改进
    let zanTxt = '这个内容写得很好，值得表扬';
    let caiTxt = '这个内容有待提高，需要改进';
    const { start, end, text, type, position, version_no } = curOperationType.data;
    let reason = ipt ? ipt : type === 1 ? zanTxt : caiTxt;
    let body = {
      document_uuid: documentUUID,
      target_content: text,
      feedback_type: type,
      reason,
      start: start,
      end: end,
      position,
      version_no,
    };
    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    const res = await feedbacksComment(body);
    if (res.code === 0) {
      let zancaiTip = {
        key: nanoid(),
        type: 'userZanCai',
        data: {
          type,
          reason,
          target_content: text,
          range: curOperationType.data,
        },
      };
      setTimeout(() => {
        setAILogs((prev) => [...prev, zancaiTip]);
        updateState({
          robotLoading: false,
        });
        //发送完毕 更新zan和踩的样式
        updateState({
          curOperationType: {
            type: 'updateZanCai',
            data: curOperationType.data,
          },
        });
      }, 500);
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //提交 - 聊天
  const submitChat = async (keyword: any) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '小麦随时为您提供帮助，如提供思路、查询资料等',
      });
      return;
    }
    let userInput = {
      key: nanoid(),
      type: 'userRecover',
      data: keyword,
    };
    setAILogs((prev) => [...prev, userInput]);
    updateState({
      robotLoading: true,
    });
    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    let body = {
      query: keyword,
    };
    const res = await helpChat(body);
    if (res.code === 0) {
      //区分命中和没命中
      if (res?.data?.cognitions.length > 0) {
        // 对应是文章来源的操作
        let lookSource = {
          key: nanoid(),
          type: 'lookSource',
          data: res?.data?.cognitions,
        };
        setAILogs((prev) => [...prev, lookSource]);
      } else {
        //添加通用的系统文字回复类型
        let systemTxtRecover = {
          key: nanoid(),
          type: 'systemTxtRecover',
          data: res?.data?.content,
        };
        setAILogs((prev) => [...prev, systemTxtRecover]);
      }

      updateState({
        robotLoading: false,
      });
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //查找参考资料 请求
  const getFindInfo = async (keyword: any, isAddRecover = true) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '请您输入要查找的资料内容',
      });
      return;
    }
    if (isAddRecover) {
      //将用户输入的指令添加到对话历史
      let userInput = {
        key: nanoid(),
        type: 'userRecover',
        data: keyword,
      };
      setAILogs((prev) => [...prev, userInput]);
    }
    updateState({
      robotLoading: true,
    });
    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    let body = {
      query: keyword,
    };
    let res = await freeSearch(body);
    if (res.code === 0) {
      if (res?.data?.articles.length > 0) {
        //假如有小模型回答 先展示小模型 然后再展示命中
        const articlesWithKeyword = res.data.articles.map((article: any) => ({
          ...article,
          query: keyword, //query 用于查询相关搜索的值
          keyword: keyword, //获取小模型时的原始输入值 相关搜索时传ids 需要用keyword来匹配确定是否是同一组的id
        }));
        let systemTxtRecover = {
          key: nanoid(),
          type: 'miniModelArticle',
          isTypewriter: true,
          data: articlesWithKeyword,
        };
        setAILogs((prev) => [...prev, systemTxtRecover]);

        setTimeout(() => {
          let lookRecommend = {
            key: nanoid(),
            type: 'lookRecommend',
            data: {
              ...articlesWithKeyword[0],
              keyword,
              query: keyword,
            },
          };
          setAILogs((prev) => [...prev, lookRecommend]);
        }, 1000 + (800 * res?.data?.articles.length + 1));
      }

      //区分命中和没命中
      if (res?.data?.cognitions.length > 0) {
        setTimeout(() => {
          // 找参考资料 返回的资料
          let addObj = {
            key: nanoid(),
            type: 'findProfileResult',
            data: res?.data?.cognitions,
          };
          setAILogs((prev) => [...prev, addObj]);
        }, 2000 + (800 * res?.data?.articles.length || 0));
      }
      updateState({
        robotLoading: false,
        curOperationType: {
          type: 'input',
          data: null,
        },
      });
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };

  //启发写作思路 请求
  const getInspireIdeas = async (keyword: any) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '请您输入的写作思路',
      });
      return;
    }
    //将用户输入的指令添加到对话历史
    // let userInput = {
    //   key: nanoid(),
    //   type: 'userRecover',
    //   data: keyword,
    // };
    // setAILogs((prev) => [...prev, userInput]);

    updateState({
      robotLoading: true,
    });
    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    let body = {
      theme: keyword,
    };
    const res = await viewpoints(body);
    if (res.code === 0) {
      if (res?.data?.length > 0) {
        // 启发写作思路 返回的资料
        let addObj = {
          key: nanoid(),
          type: 'thinkingResult',
          data: {
            list: res?.data,
            keyword,
          },
        };
        setAILogs((prev) => [...prev, addObj]);
        setTimeout(() => {
          // 更多思路和观点
          let addObj2 = {
            key: nanoid(),
            type: 'thinkingMore',
            data: keyword,
          };
          setAILogs((prev) => [...prev, addObj2]);
        }, 1000);
      }
      updateState({
        robotLoading: false,
      });
      updateState({
        curOperationType: {
          type: 'input',
          data: null,
        },
      });
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //确定大纲主题
  const getMainPointTitle = async (keyword: any, isAddRecover = true) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '请您输入的文章主题',
      });
      return;
    }

    if (isAddRecover) {
      //将用户输入的指令添加到对话历史
      let userInput = {
        key: nanoid(),
        type: 'userRecover',
        data: keyword,
      };
      setAILogs((prev) => [...prev, userInput]);
    }
    updateState({
      robotLoading: true,
    });
    form.resetFields();
    setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
    let body = {
      write_session_id: writing_session_id,
      title: keyword,
    };
    const res = await mainPointTitle(body);
    if (res.code === 0) {
      updateState({
        robotLoading: false,
      });
      //添加通用的系统文字回复类型
      let systemTxtRecover = {
        key: nanoid(),
        isTypewriter: false,
        type: 'systemTxtRecover',
        data: ['小麦已收到您的文章主题'],
      };
      setAILogs((prev) => [...prev, systemTxtRecover]);

      //触发文章主题和文章大纲的更新
      props.triggerArticleMain();
      setTimeout(() => {
        getInspireIdeas(keyword);
      }, 100);
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //意图判定
  const getFreeIntention = async (keyword: any) => {
    //判断是否有输入
    if (!isNotEmpty(keyword)) {
      message.open({
        type: 'info',
        content: '请您输入的指令......',
      });
      return;
    }

    let body = {
      query: keyword,
    };
    //将用户输入的指令添加到对话历史
    let userInput = {
      key: nanoid(),
      type: 'userRecover',
      data: keyword,
    };
    setAILogs((prev) => [...prev, userInput]);
    updateState({
      robotLoading: true,
    });
    let res = await freeIntention(body);
    if (res.code === 0) {
      let intention = res.data?.intention;
      let intentionType: any = {
        search: 'findInfo',
        upload: 'uploadInfo',
        inspire: 'inspireIdeas',
        write: 'generateArticle',
      };
      updateState({
        curOperationType: {
          type: intentionType[intention] || 'input',
          data: null,
        },
      });
      updateState({
        robotLoading: false,
      });
      if (intention === 'search') {
        //找参考资料
        getFindInfo(keyword, false);
      } else if (intention === 'upload') {
        //上传
        setShowUpload(true); //显示 - 文件上传框
        form.resetFields();
        setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
      } else if (intention === 'inspire') {
        //文章大纲主题确定
        // await getMainPointTitle(keyword, false);
        //进入启发写作思路模式
        updateState({
          curOperationType: {
            type: 'inspireIdeas',
            data: null,
          },
        });
        //添加通用的系统文字回复类型
        let systemTxtRecover = {
          key: nanoid(),
          type: 'systemTxtRecover',
          data: ['请告诉我文章的主题'],
        };
        setAILogs((prev) => [...prev, systemTxtRecover]);
        form.resetFields();
        setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
      } else if (intention === 'write') {
        //生成文章
        form.resetFields();
        setIpt(''); //重置表单的时候 页面上的值清空后 实际上还是有值的 需要手动清空
        //选择篇数
        let selectNum = {
          key: nanoid(),
          type: 'selectNum',
          data: null,
        };
        setAILogs((prev: any) => [...prev, selectNum]);
        setTimeout(() => {
          updateState({
            curOperationType: {
              type: 'input',
              data: null,
            },
          });
        }, 100);
      }
    } else {
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //踩的反馈提交
  const submitFeedbackCai = async (item: any, item2: any) => {
    let body = {
      query_string: item?.data?.query_string,
      query_result: item?.data?.query_result,
      source: '小模型',
      type: item?.data?.type,
      reason_ids: [],
      other_reason: item2,
    };

    let res = await search_feedback(body);
    if (res.code === 0) {
      let caiTxt = '收到您的反馈，我会总结经验，努力改进的。';
      //显示输入的内容
      let zancaiTip = {
        key: nanoid(),
        type: 'userZanCai',
        data: {
          type: item?.data?.type,
          reason: item2,
          target_content: item?.data?.sentence,
          range: null,
        },
      };

      setTimeout(() => {
        setAILogs((prev: any) => [...prev, zancaiTip]);
        //取消点踩模式
        updateState({
          robotLoading: false,
          curOperationType: {
            type: 'cancelZanCai',
            data: null,
          },
        });

        form.resetFields();
        setIpt('');
        // 系统回复文案
        let systemTxtRecover = {
          key: nanoid(),
          type: 'systemTxtRecover',
          spend: 30,
          data: [caiTxt],
        };
        setAILogs((prev: any) => [...prev, systemTxtRecover]);
      }, 500);
    } else {
      message.error(res.msg);
    }
  };
  //点击发送按钮
  const handleSubmit = async (keyword: any) => {
    if (curOperationType.type === 'input') {
      getFreeIntention(keyword);
    } else if (curOperationType.type === 'findInfo') {
      //找参考资料
      getFindInfo(keyword);
    } else if (curOperationType.type === 'uploadInfo') {
      //上传参考资料
    } else if (curOperationType.type === 'inspireIdeas') {
      //文章大纲主题确定
      await getMainPointTitle(keyword);
    } else if (curOperationType.type === 'generateArticle') {
      //生成文章
    } else if (curOperationType.type === 'zan' || curOperationType.type === 'cai') {
      //点赞和点踩
      submitZanCai();
    } else if (curOperationType.type === 'caiFeedback') {
      //小模型 点踩的反馈
      submitFeedbackCai(curOperationType, keyword);
    }
    return;
    // 聊天
    if (orderSelect === '2') {
      await submitChat(keyword);
      return;
    } else if (curOperationType.type === 'zan' || curOperationType.type === 'cai') {
      //点赞和点踩
      submitZanCai();
    } else {
      //用户输入指令的处理
      generateArticle(keyword);
      return;
    }

    console.log(ref);
  };
  //回车触发提交
  const handleKeyDown = (e: any) => {
    if (e.keyCode === 13) {
      handleSubmit(ipt);
    }
  };

  //停止轮询
  const stopSubmit = () => {
    stopStruct();
  };

  //对话框内容变动时 自动滑动到底部
  useEffect(() => {
    scrollToBottom();
  }, [aiLogs]);

  //当前选中文章变动时清空输入框
  useEffect(() => {
    form.resetFields();
    setIpt('');
  }, [currentDocIndex]);

  //监听机器人loading
  useEffect(() => {
    //添加机器人等待
    if (robotLoading && !aiLogs.some((log) => log.type === 'robotLoading')) {
      const robotLoad = {
        key: nanoid(),
        type: 'robotLoading',
      };
      setAILogs((prev) => [...prev, robotLoad]);
    }
    //删除
    if (!robotLoading && aiLogs.some((log) => log.type === 'robotLoading')) {
      setAILogs((prev) => prev.filter((log) => log.type !== 'robotLoading'));
    }
  }, [robotLoading, aiLogs]);

  //监听左侧文章组件点赞 点踩 评分的操作
  useEffect(() => {
    //操作类型 评分score 点赞zan 踩cai cancelZanCai取消赞和踩 输入文字input
    if (curOperationType) {
      let orderType1 = ['zan', 'cai', 'input', 'fanxie', 'gaixie']; //赞和踩 input都属于指令
      //切换到对应的select
      if (orderType1.includes(curOperationType.type)) {
        setOrderSelect('1');
      }
      //评分成功
      if (curOperationType.type === 'score') {
        let userInput = {
          key: nanoid(),
          type: 'userRecover',
          data: '我已给这篇文章评分，继续加油。',
        };
        setAILogs((prev) => [...prev, userInput]);
        setTimeout(() => {
          let scoreTip = {
            key: nanoid(),
            type: 'scoreTip',
            data: '好的，收到您的评价！我会结合您的反馈继续改进，争取做的更好。',
          };
          setAILogs((prev) => [...prev, scoreTip]);
        }, 500);
      }
      if (curOperationType.type === 'zan') {
        setIptPlaceholder('请简要写出点赞原因,  小麦会根据您的描述快速学习，变得更加懂你');
      }
      if (curOperationType.type === 'cai') {
        setIptPlaceholder('请简要写出点踩原因,  小麦会根据您的描述快速学习，变得更加懂你');
      }
      if (curOperationType.type === 'input') {
        setIptPlaceholder('');
      }
      if (curOperationType.type === 'caiFeedback') {
        setIptPlaceholder('请简要写出点踩原因,  小麦会根据您的描述快速学习，变得更加懂你');
      }
    }
  }, [curOperationType]);

  useEffect(() => {
    if (orderSelect) {
    }
  }, [orderSelect]);

  // 指令下拉 默认回到文章input模式
  // const changeOrder = (val: any) => {
  //   //1是指令 2是聊天
  //   setOrderSelect(val);
  //   if (val === '1') {
  //     updateState({
  //       curOperationType: {
  //         type: 'input',
  //         data: null,
  //       },
  //     });
  //   } else {
  //     updateState({
  //       curOperationType: {
  //         type: 'chat',
  //         data: null,
  //       },
  //     });
  //     setIptPlaceholder('小麦随时为您提供帮助，如提供思路、查询资料等');
  //   }
  // };
  //取消赞和踩
  const cancleZanCai = (data: any) => {
    updateState({
      curOperationType: {
        type: 'cancelZanCai',
        data: data,
      },
    });
  };
  //切换当前操作
  const toggleChilrenHandle = (data: any) => {
    AiCommandLogsRef?.current?.toggleHandle(data);
  };

  //文件上传成功后的回调
  const uploadSuccess = (data: any) => {
    console.log(data);
    //切换回输入模式
    setShowUpload(false);
    updateState({
      curOperationType: {
        type: 'input',
        data: null,
      },
    });
    //添加文件结果框
    let uploadResult = {
      key: nanoid(),
      type: 'uploadResult',
      data: data,
    };
    setAILogs((prev) => [...prev, uploadResult]);
    //添加文件参考方向选择框
    let fileSelect = {
      key: nanoid(),
      type: 'fileSelect',
      data: data,
    };
    setAILogs((prev) => [...prev, fileSelect]);
  };
  //预留触发的方法
  useImperativeHandle(ref, () => ({
    setAILogs,
    toggleChilrenHandle,
    highClassHandle,
  }));

  //上传返回
  const handleReturn = () => {
    //切换回输入模式
    updateState({
      curOperationType: {
        type: 'input',
        data: null,
      },
    });
  };
  // useEffect(() => {
  //   if(aiLogs.length>0){
  //     console.log(aiLogs);

  //   }
  // }, [aiLogs])
  return (
    <div className="highClassTalkBox" style={{ display: visible ? 'flex' : 'none' }}>
      <div className="highClassTalkTitle">写作实习生 - 小麦</div>
      <div
        className={`commandHistoryWrap commandHistoryScroll ${
          curOperationType.type === 'zan' || curOperationType.type === 'cai' ? 'haszancai' : ''
        }`}
        ref={messagesEnd}
      >
        {/* {!showProgress && (
          <Divider className="dividerLine" dashed plain>
            以下指令只针对文章 {currentDocIndex}
          </Divider>
        )} */}
        <AiCommandLogs
          ref={AiCommandLogsRef}
          highClassHandle={highClassHandle}
          aiLogs={aiLogs}
          setAILogs={setAILogs}
          scrollToBottom={scrollToBottom}
          scrollToEle={scrollToEle}
          setShowUpload={setShowUpload}
          generateSubmit={props.generateSubmit}
          triggerReference={props.triggerReference}
          triggerArticleMain={props.triggerArticleMain}
        ></AiCommandLogs>
      </div>
      <div className="commandSendWrap">
        {!showUpload ? (
          <div className="">
            <div className="handleTagBox">
              {highClassHandle.map((item: any) => (
                <Button size="small" onClick={() => toggleChilrenHandle(item)} key={nanoid()}>
                  {item.name}
                </Button>
              ))}
            </div>
            <div className="command-send">
              {!showProgress && (
                <div className="command-type-tag-box">
                  {/* <Select
                  bordered={false}
                  className="selectOrderType"
                  size="small"
                  value={orderSelect}
                  style={{ width: 80 }}
                  onChange={changeOrder}
                  options={[
                    { value: '1', label: '# 指令' },
                    { value: '2', label: '# 聊天' },
                  ]}
                /> */}
                  {orderSelect === '1' ? (
                    curOperationType.type === 'zan' ? (
                      <div className="command-type-tag cyan">点赞</div>
                    ) : curOperationType.type === 'cai' ? (
                      <div className="command-type-tag red">点踩</div>
                    ) : curOperationType.type === 'caiFeedback' ? (
                      <div className="command-type-tag red">点踩</div>
                    ) : (
                      <></>
                    )
                  ) : (
                    <></>
                  )}
                </div>
              )}

              <Form form={form} name="control-hooks" className="command-form">
                <Form.Item name="content">
                  <Input
                    value={ipt}
                    disabled={robotLoading}
                    bordered={false}
                    placeholder={iptPlaceholder}
                    className="question-input"
                    onChange={(e) => setIpt(e.target.value)}
                    onKeyDown={handleKeyDown}
                    autoComplete="off"
                  />
                </Form.Item>
              </Form>
              <Button
                loading={robotLoading}
                disabled={robotLoading}
                type="text"
                onClick={() => handleSubmit(ipt)}
                style={{ background: '#fff', padding: '0 6px' }}
              >
                {!robotLoading && <img src={conversion_send_icon} width={23} height={23} />}
              </Button>
              {showProgress && (
                <div className="stop-btn" onClick={() => stopSubmit()}>
                  停止
                </div>
              )}
            </div>
            {curOperationType.type === 'zan' ||
            curOperationType.type === 'cai' ||
            curOperationType.type === 'caiFeedback' ? (
              <div className="zancaiBox">
                <div className="zancai-hd">
                  <span>{curOperationType && curOperationType.data?.text}</span>
                </div>
                <span className="zancai-bd" onClick={() => cancleZanCai(curOperationType)}>
                  <CloseCircleOutlined />
                </span>
              </div>
            ) : null}
          </div>
        ) : (
          <UploadFile
            setShowUpload={setShowUpload}
            uploadSuccess={uploadSuccess}
            handleReturn={handleReturn}
          ></UploadFile>
        )}
      </div>
    </div>
  );
});

export default connect(({ highClassWrite }) => ({ highClassWrite }), null, null, {
  forwardRef: true,
})(Command);
